import ash from '@ash.ts/ash';
import { DeathThroesNode } from '../data/nodes';
import { EntityCreator } from '../util/EntityCreator';

// 延时开始新游戏
export class DeathThroesSystem extends ash.ListIteratingSystem<DeathThroesNode> {
    private creator: EntityCreator;

    public constructor(creator: EntityCreator) {
        super(DeathThroesNode);
        this.creator = creator;
    }

    public updateNode(node: DeathThroesNode, time: number): void {
        node.death.countdown -= time;
        if (node.death.countdown <= 0) {
            this.creator.destroyEntity(node.entity);
        }
    }
}
